package com.augurit.common.base.extmodel.inner;

import javax.servlet.http.HttpServletRequest;

import com.augurit.common.base.extmodel.base.BaseTreeNode;

/**
 * 机构人员树（Ext扩展组件）的java类
 */
public class GroupTreeNode extends BaseTreeNode<GroupTreeNode> {
	
	// ****************** 静态属性 ******************
	// 机构人员树的各类节点的图标CSS
	public static final String CLS_ORG = "icon-org";
	public static final String CLS_POSITION = "icon-position";
	public static final String CLS_USER_MALE = "icon-user-male";
	public static final String CLS_USER_FEMALE = "icon-user-female";
	
	private String partyType;
	private Long orgId;				//机构ID
	private Long groupId;           //工作组id
	private Long posId;				//岗位ID
	private Long userId;			//用户ID
	private boolean isCanManager;	//是否有有该节点的右键菜单权限和左键单击权限
	
	private Long parentOrgId;		//工作组结点的隶属机构id
	private String parentOrgName;	//工作组结点的隶属机构名称
	private Long parentGroupId;		//工作组、岗位结点的父工作组id
	private String parentGroupName; //工作组、岗位结点的父工作组名称
	private Long parentPosId;		//岗位的父岗位id
	private String parentPosName;	//岗位的父岗位名称
	
	/**
	 * 根据Request参数构造GroupTreeNode对象
	 * @param request
	 * @return
	 */
	public static GroupTreeNode build(HttpServletRequest request){
		GroupTreeNode node = new GroupTreeNode();
		node.setPartyType(request.getParameter("partyType"));
		
		String orgIdStr = request.getParameter("orgId");
		node.setOrgId(orgIdStr != null && orgIdStr.trim().length() > 0 ? Long.valueOf(orgIdStr) : null);
		
		String groupIdStr = request.getParameter("groupId");
		node.setGroupId(groupIdStr != null && groupIdStr.trim().length() > 0 ? Long.valueOf(groupIdStr):null);
		
		String posIdStr = request.getParameter("posId");
		node.setPosId(posIdStr != null && posIdStr.trim().length() > 0 ? Long.valueOf(posIdStr) : null);
		
		String userIdStr = request.getParameter("userId");
		node.setUserId(userIdStr != null && userIdStr.trim().length() > 0 ? Long.valueOf(userIdStr) : null);
		
		String parentOrgIdStr = request.getParameter("parentOrgId");
		node.setParentOrgId(parentOrgIdStr != null && parentOrgIdStr.trim().length() > 0 ? Long.valueOf(parentOrgIdStr) : null);
		
		String parentGroupIdStr = request.getParameter("parentGroupId");
		node.setParentGroupId(parentGroupIdStr != null && parentGroupIdStr.trim().length() > 0 ? Long.valueOf(parentGroupIdStr) : null);
		
		String parentPosIdStr = request.getParameter("parentPosId");
		node.setUserId(parentPosIdStr != null && parentPosIdStr.trim().length() > 0 ? Long.valueOf(parentPosIdStr) : null);
		
		node.setParentOrgName(request.getParameter("parentOrgName"));
		node.setParentGroupName(request.getParameter("parentGroupName"));
		node.setParentPosName(request.getParameter("parentPosName"));
		node.setText(request.getParameter("text"));
		
		
		return node;
	}

	// ****************** getter和setter方法 ******************

	public String getPartyType() {
		return partyType;
	}

	public void setPartyType(String partyType) {
		this.partyType = partyType;
	}

	public Long getOrgId() {
		return orgId;
	}

	public void setOrgId(Long orgId) {
		this.orgId = orgId;
	}

	public Long getGroupId() {
		return groupId;
	}

	public void setGroupId(Long groupId) {
		this.groupId = groupId;
	}

	public Long getPosId() {
		return posId;
	}

	public void setPosId(Long posId) {
		this.posId = posId;
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public boolean isCanManager() {
		return isCanManager;
	}

	public void setCanManager(boolean isCanManager) {
		this.isCanManager = isCanManager;
	}

	public Long getParentOrgId() {
		return parentOrgId;
	}

	public void setParentOrgId(Long parentOrgId) {
		this.parentOrgId = parentOrgId;
	}

	public String getParentOrgName() {
		return parentOrgName;
	}

	public void setParentOrgName(String parentOrgName) {
		this.parentOrgName = parentOrgName;
	}

	public Long getParentGroupId() {
		return parentGroupId;
	}

	public void setParentGroupId(Long parentGroupId) {
		this.parentGroupId = parentGroupId;
	}

	public String getParentGroupName() {
		return parentGroupName;
	}

	public void setParentGroupName(String parentGroupName) {
		this.parentGroupName = parentGroupName;
	}

	public Long getParentPosId() {
		return parentPosId;
	}

	public void setParentPosId(Long parentPosId) {
		this.parentPosId = parentPosId;
	}

	public String getParentPosName() {
		return parentPosName;
	}

	public void setParentPosName(String parentPosName) {
		this.parentPosName = parentPosName;
	}
}
